﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using IDAL.RF.Repair;
using Model.RF.Repair;

namespace DAL.RF.Repair
{
    public class ProductTypeIDChange : BaseRepository<ProductTypeIDChangeInfo>,IProductTypeIDChange
    {
        #region 静态变量定义部分
        private const string PARM_PRODUCTTYPEIDCHANGE_PRODUCTSN = "@ProductSN";
        private const string PARM_PRODUCTTYPEIDCHANGE_OLDPRODUCTTYPEID = "@OldProductTypeID";
        private const string PARM_PRODUCTTYPEIDCHANGE_NEWPRODUCTTYPEID = "@NewProductTypeID";
        private const string PARM_PRODUCTTYPEIDCHANGE_RECORDTIME = "@RecordTime";
        private const string PARM_PRODUCTTYPEIDCHANGE_USERID = "@UserID";
        #endregion


        #region 检索数据部分
        public ProductTypeIDChangeInfo LoadEntity<T1>(T1 packageSN)
        {
            return null;
        }

        public IList<ProductTypeIDChangeInfo> LoadEntities()
        {
            return null;
        }
        #endregion


        #region 重写基类部分
        public override ProductTypeIDChangeInfo GetEntityRecord(SqlDataReader rdr)
        {
            ProductTypeIDChangeInfo pro = new ProductTypeIDChangeInfo
            {
                ProductSN = rdr.GetValue(0).ToString(),
                OldProductTypeID = rdr.GetValue(1).ToString(),
                NewProductTypeID = rdr.GetValue(2).ToString(),
                RecordTime = rdr.GetDateTime(3),
                UserID = rdr.GetValue(4).ToString()
            };
            return pro;
        }

        public override ProductTypeIDChangeInfo GetEntityRecord()
        {
            ProductTypeIDChangeInfo pro = new ProductTypeIDChangeInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "PackageProductTypeIDChangeLog_Insert";
        }

        //public override string GetInsertsp()
        //{
        //    return null;
        //}

        //public override string GetInsertsp()
        //{
        //    return null;
        //}

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_PRODUCTSN, SqlDbType.NVarChar, 50);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_OLDPRODUCTTYPEID, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_NEWPRODUCTTYPEID, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_RECORDTIME, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_PRODUCTTYPEIDCHANGE_USERID, SqlDbType.Char , 10),
                };
            return parms;
        }

        public override void SetParameters(ProductTypeIDChangeInfo packageSNChange, params SqlParameter[] Parms)
        {
            Parms[0].Value = packageSNChange.ProductSN;
            Parms[1].Value = packageSNChange.OldProductTypeID;
            Parms[2].Value = packageSNChange.NewProductTypeID;
            Parms[3].Value = packageSNChange.RecordTime;
            Parms[4].Value = packageSNChange.UserID;
        }
        #endregion
    }
}
